<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>生命周期</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="">
</head>

<body>
    <div id="react"> </div>
    <!--准备好一个容器-->
    <!--引入react核心库,核心库必须先引入-->
    <script type="text/javascript" src="./js/17.1js/react.development.js"></script>
    <!--引入react-dom, 用于支持react操作DOM-->
    <script type="text/javascript" src="./js/17.1js/react-dom.development.js"></script>
    <!--引入babel,用于将jsx转为js-->
    <script type="text/javascript" src="./js/17.1js/babel.min.js"></script>


    <script type="text/babel">

        class Time extends React.Component{
     
        state={date:new Date()}

        componentDidMount(){
            setInterval(() => {
             let {date} =this.state
             this.setState({date:new Date()})
            }, 360);
        }
    

        render(){
            return (
                <div>
                    <h1>hello</h1>
                      {/*input输入的值不会变，说明Diff进行DOM对比，后直接用了上次的节点input*/}
                    <input type="text"/>
                    {/*toTimeString:以特定于实现的格式显示星期几，月，日和年 */}
                    <span>
                        现在的时间：{this.state.date.toTimeString()}
                         {/*diff算法进行DOM对比时,发现span标签修改了，所以的重新转真实dom，但是对span标签内的标签input还是会对比，发现没变，就会直接用上次生成的DOM了*/}
                        <input type="text"/>
                        </span>
                </div>
            )}

        }

      ReactDOM.render(<Time/>, document.getElementById("react"));
    </script>

    <style>
        .new {
            width: 200px;
            height: 40px;
        }

        .ulone {
            width: 200px;
            height: 150px;
            background: blanchedalmond;
            overflow-y: auto;

        }
    </style>

</body>

</html>